package com.epoint.pjq.core.mqtt;



/**
 * 
 * @author lilin
 * @date 2016年9月14日 上午9:37:32
 * @annotation MQTT客户端连接线程
 */

public class SMP_MQTT_ConnectionThread extends Thread {
	
	@Override
	public void run() {

		SMP_MQTT_Bizlogic.sendLogBroadcast("一个线程尝试开启连接...");

		String topic 			= SMP_MQTT_Service.topic;
		String KEEPALIVETIME 	= SMP_MQTT_Service.keepalivetime;
		
		if(KEEPALIVETIME.equals(""))
		{
			KEEPALIVETIME = "10";
		}

		SMP_MQTT_EpointClient mqttClient = SMP_MQTT_EpointClient.getInstance();

		synchronized (mqttClient) {
			if(mqttClient.isConnected())
			{
				SMP_MQTT_Bizlogic.sendLogBroadcast("客户端已经是连接状态，多线程重连退出...");
				return;
			}
			mqttClient.initClient(Integer.parseInt(KEEPALIVETIME), topic);
		}
	}
}
